//
//  BaseModle.h
//  demo
//
//  Created by vonchenchen on 2021/3/19.
//  Copyright © 2021 vonchenchen. All rights reserved.
//

#ifndef BaseModle_h
#define BaseModle_h

#include "ToyMath.h"
#include <unordered_map>
#include <utility>
#include "ToyTexture.h"

using namespace ToyCube;

struct VertexAttrib {
    Vec<4, float> pos;
    Vec<2, float> uv;
    Vec<3, float> normal;
};

struct Light{
    Vec<3, float> pos;
    Vec<3, float> intensity;
};

//顶点 uv坐标 顶点法线方向向量
const VertexAttrib CUBE_MODLE[] = {
    { {  1, -1,  1, 1}, { 0, 0 }, {1, -1,  1}},
    { { -1, -1,  1, 1}, { 0, 0 }, {-1, -1,  1}},
    { { -1,  1,  1, 1}, { 0, 0 }, {-1,  1,  1}},
    { {  1,  1,  1, 1}, { 0, 0 }, {1,  1,  1}},
    { {  1, -1, -1, 1}, { 0, 0 }, {1, -1, -1}},
    { { -1, -1, -1, 1}, { 0, 0 }, {-1, -1, -1}},
    { { -1,  1, -1, 1}, { 0, 0 }, {-1,  1, -1}},
    { {  1,  1, -1, 1}, { 0, 0 }, {1,  1, -1}},
};
const int CUBE_VERTEX_INDEX[][3] = {
    {0, 1, 2}, {2, 3, 0}, //前
    {4, 5, 6}, {6, 7, 4}, //后
    {1, 5, 6}, {6, 2, 1}, //左
    {4, 0, 3}, {3, 7, 4}, //右
    {3, 2, 6}, {6, 7, 3}, //上
    {0, 1, 5}, {5, 4, 0}, //下
};

void LoadBaseCube(VertexAttrib **mesh);
void ReleaseBaseCube(VertexAttrib *mesh);

#define TEX_COLOR_RED 0
#define TEX_COLOR_GREEN 1
#define TEX_COLOR_BLUE 2
#define TEX_COLOR_YELLOW 3
#define TEX_COLOR_WHITE 4
#define TEX_COLOR_ORANGE 5

void InitCubeColorTexture();
ToyTexture *GetCubeColorTexture(const int color);

#endif /* BaseModle_h */
